﻿<Tree TItem="Known.MenuItem" ShowIcon
	DefaultExpandParent="Model.ExpandParent"
	DefaultSelectedKeys="Model.SelectedKeys"
	DataSource="Model.Data" OnClick="OnTreeClick"
	KeyExpression="x => x.DataItem.Id"
	TitleExpression="x => x.DataItem.Name"
	IconExpression="x => x.DataItem.Icon"
	ChildrenExpression="x => x.DataItem.Children"
	IsLeafExpression="x => x.DataItem.Children?.Count == 0" />

@code {
	[Parameter] public TreeModel Model { get; set; }

	private void OnTreeClick(TreeEventArgs<Known.MenuItem> e)
	{
		var item = e.Node.DataItem;
		Model.OnNodeClick?.Invoke(item);
	}
}